# -*- coding: utf-8 -*-
from odoo import models, api, fields, tools
from odoo.exceptions import UserError
import re


class project_base(models.Model):

    _name = "proman.project_base"
    _description = "项目定义"
    _table = "proman_project_base"
    _order = "sequence"

    sequence = fields.Integer(string="排序",translate = 0)
    name = fields.Char(string="项目名称",help = '请输入项目名称',translate = 0)
    project_category_id = fields.Many2one(string="项目类型",comodel_name = 'proman.project_category',translate = 0)
    industry_category = fields.Many2one(string="所属行业",comodel_name = 'setcent.industry_category',translate = 0)
    company_id = fields.Many2one(string="所属公司",comodel_name = 'res.company',default = lambda self:self.env.company,required = 1,translate = 0)
    lender_partner_id = fields.Many2one(string="贷款方名称",comodel_name = 'res.partner',domain = [('is_company','=',True)],translate = 0)
    lender_contactor = fields.Many2one(string="贷款方联系人",comodel_name = 'res.partner',domain = [('is_company','=',False)],translate = 0)
    debit_partner_id = fields.Many2one(string="借款方名称",comodel_name = 'res.partner',domain = [('is_company','=',True)],translate = 0)
    debit_contactor = fields.Many2one(string="借方联系人",comodel_name = 'res.partner',domain = [('is_company','=',False)],translate = 0)
    manage_department_id = fields.Many2one(string="管理机构",comodel_name = 'hr.department',default = lambda self: self.env.user.default_department,translate = 0)
    region_ids = fields.Many2many(string="涉及项目区",comodel_name = 'setcent.region',translate = 0)
    file_no = fields.Char(string="文件号",translate = 0)
    start_date = fields.Date(string="开始日期",translate = 0)
    end_date = fields.Date(string="结束日期",translate = 0)
    user_id = fields.Many2one(string="负责人",comodel_name = 'res.users',translate = 0)
    currency_id = fields.Many2one(string="货币",comodel_name = 'res.currency',default = lambda self:self.env['res.currency'].search([('name','=','CNY')]),translate = 0)
    amount = fields.Monetary(string="贷款金额",help = '请输入贷款金额',translate = 0)
    exchange_rate = fields.Float(string="汇率",translate = 0)
    amount_local = fields.Float(string="折合本币金额",help = '请输入折合本币金额',translate = 0)
    url = fields.Char(string="相关链接",translate = 0)
    memo = fields.Html(string="备注说明",translate = 0)
    image = fields.Binary(string="相关文件照片",translate = 0)
    attachment = fields.Many2many(string="相关附件",comodel_name = 'ir.attachment',translate = 0)
    _check_company_auto = 1
